package time;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Test3<XPTime, startTime, endTime> {
    public static void main(String[] args) throws ParseException {
        String start = "2023-11-11 0:0:0";
        String end = "2023-11-11 0:10:0";
        String XJ = "2023-11-11 0:03:04";
        String XP = "2023-11-11 0:10:05";

        // 字符串转换成日期
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date startDT = sdf.parse(start);
        Date endDT = sdf.parse(end);
        Date XJDT = sdf.parse(XJ);
        Date XPDT = sdf.parse(XP);

        // 时间转换成毫秒值
        long startTime = startDT.getTime();
        long endTime = endDT.getTime();
        long XJTime = XJDT.getTime();
        long XPTime = XPDT.getTime();

        if (XJTime >= startTime && XJTime <= endTime) {
            System.out.println("秒杀成功");
        } else {
            System.out.println("秒杀失败");
        }

        if (XPTime >= startTime && XPTime <= endTime) {
            System.out.println("秒杀成功");
        } else {
            System.out.println("秒杀失败");
        }
    }
    public static final int YEAR = 1;
}